package main
import "fmt"
import "math/rand"	//为了使用随机数
func main(){
	var num [10]int
	var i int
	var j int
	for i = 0; i < len(num); i++{
		num[i] = rand.Intn(100)	//随机赋值 0 ~ 100
	}
	
	fmt.Println("\n生成的随机数是：")
	
	for i = 0; i < len(num); i++{
		fmt.Print(num[i]," ")	//打印出随机赋的值
	}
	
	for i = 0; i < len(num); i++{
		for j = i; j < len(num); j++{
			if num[i] < num[j]{	//如果 num[i] 小于 num[j]，就把num[j]放前面，把大数放前面
				
				//两个数互换，类似于C语言的
				//temp = num[i]; num[i] = num[j]; num[j] = temp;
				num[i], num[j] = num[j], num[i]	
			}
		}
	}
	
	fmt.Println("\n经过排序后的结果是：")
	for i = 0; i < len(num); i++{
		fmt.Print(num[i]," ")	//打印出随机赋的值
	}
}
